﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kooboo.HtmlFunc.Providers;

namespace Kooboo.CMS.SiteConverter.Parser.NVelocity
{
    public class MenuParser : ParserBase, IParser<IMenu>
    {
        #region IParser<IMenu> Members

        public void Parse(IMenu obj)
        {
            var loopStart = @"
    #foreach ($item in $MenuHelper.Top())
    #each
        #if($item.Navigation.Show)";
            var classFormat = "#if($MenuHelper.IsCurrent($item)) 'current' #end";
            var linkFormat = "$Html.FrontHtml().PageLink($item.LinkText, $item.FullName)";
            var linkHref = @"$Url.FrontUrl().PageUrl($item.FullName)";
            var linkText = @"$item.LinkText";
            var loopEnd = @"
        #end
    #end";
            Razor.MenuParser.Format(obj, loopStart, loopEnd, classFormat, linkFormat, linkHref, linkText);
        }

        #endregion
    }
}
